package com.gpt.article.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.gpt.article.domain.GptTxtClassItem;
import com.gpt.article.service.IGptTxtClassItemService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 分类项Controller
 * 
 * @author zhuzi
 * @date 2023-12-23
 */
@RestController
@RequestMapping("/article/classItem")
public class GptTxtClassItemController extends BaseController
{
    @Autowired
    private IGptTxtClassItemService gptTxtClassItemService;

    /**
     * 查询分类项列表
     */
    @PreAuthorize("@ss.hasPermi('article:classItem:list')")
    @GetMapping("/list")
    public TableDataInfo list(GptTxtClassItem gptTxtClassItem)
    {
        startPage();
        List<GptTxtClassItem> list = gptTxtClassItemService.selectGptTxtClassItemList(gptTxtClassItem);
        return getDataTable(list);
    }

    /**
     * 导出分类项列表
     */
    @PreAuthorize("@ss.hasPermi('article:classItem:export')")
    @Log(title = "分类项", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GptTxtClassItem gptTxtClassItem)
    {
        List<GptTxtClassItem> list = gptTxtClassItemService.selectGptTxtClassItemList(gptTxtClassItem);
        ExcelUtil<GptTxtClassItem> util = new ExcelUtil<GptTxtClassItem>(GptTxtClassItem.class);
        util.exportExcel(response, list, "分类项数据");
    }

    /**
     * 获取分类项详细信息
     */
    @PreAuthorize("@ss.hasPermi('article:classItem:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(gptTxtClassItemService.selectGptTxtClassItemById(id));
    }

    /**
     * 新增分类项
     */
    @PreAuthorize("@ss.hasPermi('article:classItem:add')")
    @Log(title = "分类项", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GptTxtClassItem gptTxtClassItem)
    {
        return toAjax(gptTxtClassItemService.insertGptTxtClassItem(gptTxtClassItem));
    }

    /**
     * 修改分类项
     */
    @PreAuthorize("@ss.hasPermi('article:classItem:edit')")
    @Log(title = "分类项", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GptTxtClassItem gptTxtClassItem)
    {
        return toAjax(gptTxtClassItemService.updateGptTxtClassItem(gptTxtClassItem));
    }

    /**
     * 删除分类项
     */
    @PreAuthorize("@ss.hasPermi('article:classItem:remove')")
    @Log(title = "分类项", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(gptTxtClassItemService.deleteGptTxtClassItemByIds(ids));
    }
}
